home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 December / DPPCPRO1205.ISO / Assets / Interface / Main.dxr / Movie Scripts_5_Filesystem behaviours.ls < prev    next >
Encoding:
Text File  |  2005-05-20  |  3.9 KB  |  125 lines

  1. on getVolume
  2.   splitPosn = offset("\", the moviePath)
  3.   volumeName = (the moviePath).char[1..splitPosn]
  4.   return volumeName
  5. end
  6.  
  7. on fileExists path_file
  8.   fileTest = new(xtra("fileio"))
  9.   openfile(fileTest, path_file, 1)
  10.   fileResult = status(fileTest)
  11.   closeFile(fileTest)
  12.   if fileResult = 0 then
  13.     return 1
  14.   else
  15.     return 0
  16.   end if
  17. end
  18.  
  19. on launch targetPath
  20.   alert("on launch received " & targetPath)
  21.   if targetPath.char[1..4] = "http" then
  22.     gotoNetPage(targetPath, "_new")
  23.   else
  24.     if targetPath.char[1..8] = "local://" then
  25.       localHTML = getVolume() & targetPath.char[9..targetPath.length]
  26.       gotoNetPage(unescapePath(localHTML), "_new")
  27.     else
  28.       if targetPath.char[1..6] = "alert:" then
  29.         alert(targetPath.char[7..targetPath.length])
  30.       else
  31.         if targetPath.char[1..6] = "mailto" then
  32.           fileXtraObj = xtra("FileXtra4").new()
  33.           myDocsPath = fileXtraObj.fx_FolderGetSpecialPath("CSIDL_WINDOWS")
  34.           myDocsPath = myDocsPath.char[1..3]
  35.           shortcutFile = myDocsPath & "PCProjects.url"
  36.           fileIOObj = new xtra("fileio")
  37.           if fileExists(shortcutFile) then
  38.             fileIOObj.openfile(shortcutFile, 2)
  39.             delete fileIOObj
  40.             fileIOObj.closeFile()
  41.           end if
  42.           fileIOObj = new xtra("fileio")
  43.           fileIOObj.createFile(shortcutFile)
  44.           fileIOObj.openfile(shortcutFile, 2)
  45.           fileIOObj.writeString("[InternetShortcut]")
  46.           fileIOObj.writeReturn(#windows)
  47.           fileIOObj.writeString("URL=" & targetPath)
  48.           fileXtraObj.fx_FileOpenDocument(shortcutFile)
  49.           fileIOObj.closeFile()
  50.           fileXtraObj = 0
  51.           fileIOObj = VOID
  52.         else
  53.           launchByExtension(targetPath)
  54.         end if
  55.       end if
  56.     end if
  57.   end if
  58. end
  59.  
  60. on launchByExtension targetPath
  61.   pathLen = targetPath.length
  62.   startPosn = offset(".", targetPath.char[pathLen - 4..pathLen])
  63.   if targetPath.char[2..3] = ":\" then
  64.     fullPath = targetPath
  65.   else
  66.     fullPath = getVolume() & targetPath
  67.   end if
  68.   fileXtra = xtra("FileXtra4").new()
  69.   case targetPath.char[pathLen - 4 + startPosn..pathLen] of
  70.     "exe":
  71.       runResult = fileXtra.fx_FileRunApp(fullPath)
  72.     "msi":
  73.       msiHandler = fileXtra.fx_FileGetAppPath(".msi")
  74.       if msiHandler contains "msiexec" then
  75.         launchStr = QUOTE & targetPath & QUOTE
  76.         open("/I" && QUOTE & targetPath & QUOTE, "msiexec.exe")
  77.       else
  78.         alert("Windows Installer 2.0 has could not be found. It is required to install this software. Please check the system requirements box for a link to the Microsoft website")
  79.       end if
  80.       runResult = 1
  81.     "hta":
  82.       htaHandler = fileXtra.fx_FileGetAppPath(".hta")
  83.       if htaHandler contains "mshta" then
  84.         open(QUOTE & targetPath & QUOTE, "mshta.exe")
  85.       else
  86.         alert("Microsoft HTML Application host could not be found. Please contact technical support for assistance and ask them to report error code Launch_HTA to the developer")
  87.       end if
  88.     otherwise:
  89.       if fileXtra.fx_FolderExists(fullPath) then
  90.         open(unescapePath(fullPath), "explorer")
  91.         runResult = 1
  92.       else
  93.         if fileXtra.fx_FileExists(fullPath) then
  94.           runResult = fileXtra.fx_FileOpenDocument(fullPath)
  95.         end if
  96.       end if
  97.   end case
  98.   fileXtra = 0
  99.   if runResult = 0 then
  100.     alert("Failed to open: " & fullPath)
  101.   end if
  102. end
  103.  
  104. on getBannerType targetPath
  105.   pathLen = targetPath.length
  106.   startPosn = offset(".", targetPath.char[pathLen - 4..pathLen])
  107.   case targetPath.char[pathLen - 4 + startPosn..pathLen] of
  108.     "swf":
  109.       return #flash
  110.     "gif":
  111.       return #animGif
  112.     "jpeg", "jpg":
  113.       return #bitmap
  114.   end case
  115. end
  116.  
  117. on unescapePath targetPath
  118.   escapePosn = offset("\\", targetPath)
  119.   if escapePosn = 0 then
  120.     return targetPath
  121.   else
  122.     return targetPath.char[1..escapePosn] & unescapePath(targetPath.char[escapePosn + 2..targetPath.length])
  123.   end if
  124. end
  125.